package com.dxysun.design.factory.abstractfactory;

import java.util.HashMap;
import java.util.Map;

import com.dxysun.design.factory.factormethod.IRuleConfigParserFactory;
import com.dxysun.design.factory.factormethod.JsonRuleConfigParserFactory;
import com.dxysun.design.factory.factormethod.XmlRuleConfigParserFactory;

public class ConfigParserAbstractFactory
{
	private static final Map<String, IConfigParserFactory> cachedFactories = new HashMap<>();

	static
	{
		cachedFactories.put("json", new JsonConfigParserFactory());
		cachedFactories.put("xml", new XmlConfigParserFactory());
	}

	public static IConfigParserFactory getParserFactory(String type)
	{
		if (type == null || type.isEmpty())
		{
			return null;
		}
		return cachedFactories.get(type.toLowerCase());
	}
}
